<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>LCOV - self_test2.info - poll/unix/pollset.c</title>
  <link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../../index.html">top level</a> - <a href="index.html">poll/unix</a> - pollset.c<span style="font-size: 80%;"> (source / <a href="pollset.c.func.html">functions</a>)</span></td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">self_test2.info</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">45</td>
            <td class="headerCovTableEntry">105</td>
            <td class="headerCovTableEntryLo">42.9 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2011-07-03</td>
            <td></td>
            <td class="headerItem">Functions:</td>
            <td class="headerCovTableEntry">6</td>
            <td class="headerCovTableEntry">12</td>
            <td class="headerCovTableEntryLo">50.0 %</td>
          </tr>
          <tr>
            <td></td>
            <td></td>
            <td></td>
            <td class="headerItem">Branches:</td>
            <td class="headerCovTableEntry">18</td>
            <td class="headerCovTableEntry">70</td>
            <td class="headerCovTableEntryLo">25.7 %</td>
          </tr>
          <tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">           Branch data     Line data    Source code</pre>
<pre class="source">
<a name="1"><span class="lineNum">       1 </span>                :            : /* Licensed to the Apache Software Foundation (ASF) under one or more</a>
<span class="lineNum">       2 </span>                :            :  * contributor license agreements.  See the NOTICE file distributed with
<span class="lineNum">       3 </span>                :            :  * this work for additional information regarding copyright ownership.
<span class="lineNum">       4 </span>                :            :  * The ASF licenses this file to You under the Apache License, Version 2.0
<span class="lineNum">       5 </span>                :            :  * (the &quot;License&quot;); you may not use this file except in compliance with
<span class="lineNum">       6 </span>                :            :  * the License.  You may obtain a copy of the License at
<span class="lineNum">       7 </span>                :            :  *
<span class="lineNum">       8 </span>                :            :  *     http://www.apache.org/licenses/LICENSE-2.0
<span class="lineNum">       9 </span>                :            :  *
<span class="lineNum">      10 </span>                :            :  * Unless required by applicable law or agreed to in writing, software
<span class="lineNum">      11 </span>                :            :  * distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
<span class="lineNum">      12 </span>                :            :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<span class="lineNum">      13 </span>                :            :  * See the License for the specific language governing permissions and
<span class="lineNum">      14 </span>                :            :  * limitations under the License.
<span class="lineNum">      15 </span>                :            :  */
<span class="lineNum">      16 </span>                :            : 
<span class="lineNum">      17 </span>                :            : #ifdef WIN32
<span class="lineNum">      18 </span>                :            : /* POSIX defines 1024 for the FD_SETSIZE */
<span class="lineNum">      19 </span>                :            : #define FD_SETSIZE 1024
<span class="lineNum">      20 </span>                :            : #endif
<span class="lineNum">      21 </span>                :            : 
<span class="lineNum">      22 </span>                :            : #include &quot;apr.h&quot;
<span class="lineNum">      23 </span>                :            : #include &quot;apr_poll.h&quot;
<span class="lineNum">      24 </span>                :            : #include &quot;apr_time.h&quot;
<span class="lineNum">      25 </span>                :            : #include &quot;apr_portable.h&quot;
<span class="lineNum">      26 </span>                :            : #include &quot;apr_arch_file_io.h&quot;
<span class="lineNum">      27 </span>                :            : #include &quot;apr_arch_networkio.h&quot;
<span class="lineNum">      28 </span>                :            : #include &quot;apr_arch_poll_private.h&quot;
<span class="lineNum">      29 </span>                :            : #include &quot;apr_arch_inherit.h&quot;
<span class="lineNum">      30 </span>                :            : 
<span class="lineNum">      31 </span>                :            : static apr_pollset_method_e pollset_default_method = POLLSET_DEFAULT_METHOD;
<span class="lineNum">      32 </span>                :            : 
<span class="lineNum">      33 </span>                :            : #if !APR_FILES_AS_SOCKETS
<span class="lineNum">      34 </span>                :            : #if defined (WIN32)
<span class="lineNum">      35 </span>                :            : 
<span class="lineNum">      36 </span>                :            : extern apr_status_t
<span class="lineNum">      37 </span>                :            : apr_file_socket_pipe_create(apr_file_t **in,
<span class="lineNum">      38 </span>                :            :                             apr_file_t **out,
<span class="lineNum">      39 </span>                :            :                             apr_pool_t *p);
<span class="lineNum">      40 </span>                :            : 
<span class="lineNum">      41 </span>                :            : extern apr_status_t
<span class="lineNum">      42 </span>                :            : apr_file_socket_pipe_close(apr_file_t *file);
<span class="lineNum">      43 </span>                :            : 
<span class="lineNum">      44 </span>                :            : /* Create a dummy wakeup socket pipe for interrupting the poller
<span class="lineNum">      45 </span>                :            :  */
<span class="lineNum">      46 </span>                :            : static apr_status_t create_wakeup_pipe(apr_pollset_t *pollset)
<span class="lineNum">      47 </span>                :            : {
<span class="lineNum">      48 </span>                :            :     apr_status_t rv;
<span class="lineNum">      49 </span>                :            :     apr_pollfd_t fd;
<span class="lineNum">      50 </span>                :            : 
<span class="lineNum">      51 </span>                :            :     if ((rv = apr_file_socket_pipe_create(&amp;pollset-&gt;wakeup_pipe[0],
<span class="lineNum">      52 </span>                :            :                                           &amp;pollset-&gt;wakeup_pipe[1],
<span class="lineNum">      53 </span>                :            :                                           pollset-&gt;pool)) != APR_SUCCESS)
<span class="lineNum">      54 </span>                :            :         return rv;
<span class="lineNum">      55 </span>                :            :     fd.reqevents = APR_POLLIN;
<span class="lineNum">      56 </span>                :            :     fd.desc_type = APR_POLL_FILE;
<span class="lineNum">      57 </span>                :            :     fd.desc.f = pollset-&gt;wakeup_pipe[0];
<span class="lineNum">      58 </span>                :            :     /* Add the pipe to the pollset
<span class="lineNum">      59 </span>                :            :      */
<span class="lineNum">      60 </span>                :            :     return apr_pollset_add(pollset, &amp;fd);
<span class="lineNum">      61 </span>                :            : }
<span class="lineNum">      62 </span>                :            : 
<span class="lineNum">      63 </span>                :            : #else  /* !WIN32 */
<span class="lineNum">      64 </span>                :            : static apr_status_t create_wakeup_pipe(apr_pollset_t *pollset)
<span class="lineNum">      65 </span>                :            : {
<span class="lineNum">      66 </span>                :            :     return APR_ENOTIMPL;
<span class="lineNum">      67 </span>                :            : }
<span class="lineNum">      68 </span>                :            : 
<span class="lineNum">      69 </span>                :            : static apr_status_t apr_file_socket_pipe_close(apr_file_t *file)
<span class="lineNum">      70 </span>                :            : {
<span class="lineNum">      71 </span>                :            :     return APR_ENOTIMPL;
<span class="lineNum">      72 </span>                :            : }
<span class="lineNum">      73 </span>                :            : 
<span class="lineNum">      74 </span>                :            : #endif /* WIN32 */
<span class="lineNum">      75 </span>                :            : #else  /* APR_FILES_AS_SOCKETS */
<span class="lineNum">      76 </span>                :            : 
<span class="lineNum">      77 </span>                :            : /* Create a dummy wakeup pipe for interrupting the poller
<a name="78"><span class="lineNum">      78 </span>                :            :  */</a>
<span class="lineNum">      79 </span>                :            : static apr_status_t create_wakeup_pipe(apr_pollset_t *pollset)
<span class="lineNum">      80 </span>                :<span class="lineNoCov">          0 : {</span>
<span class="lineNum">      81 </span>                :            :     apr_status_t rv;
<span class="lineNum">      82 </span>                :            :     apr_pollfd_t fd;
<span class="lineNum">      83 </span>                :            : 
<span class="lineNum">      84 </span>        [<span class="branchNoExec" title="Branch 1 was not executed"> # </span><span class="branchNoExec" title="Branch 2 was not executed"> # </span>]:<span class="lineNoCov">          0 :     if ((rv = apr_file_pipe_create(&amp;pollset-&gt;wakeup_pipe[0],</span>
<span class="lineNum">      85 </span>                :            :                                    &amp;pollset-&gt;wakeup_pipe[1],
<span class="lineNum">      86 </span>                :            :                                    pollset-&gt;pool)) != APR_SUCCESS)
<span class="lineNum">      87 </span>                :<span class="lineNoCov">          0 :         return rv;</span>
<span class="lineNum">      88 </span>                :<span class="lineNoCov">          0 :     fd.reqevents = APR_POLLIN;</span>
<span class="lineNum">      89 </span>                :<span class="lineNoCov">          0 :     fd.desc_type = APR_POLL_FILE;</span>
<span class="lineNum">      90 </span>                :<span class="lineNoCov">          0 :     fd.desc.f = pollset-&gt;wakeup_pipe[0];</span>
<span class="lineNum">      91 </span>                :            : 
<span class="lineNum">      92 </span>                :            :     {
<span class="lineNum">      93 </span>                :            :         int flags;
<span class="lineNum">      94 </span>                :            : 
<span class="lineNum">      95 </span>        [<span class="branchNoExec" title="Branch 1 was not executed"> # </span><span class="branchNoExec" title="Branch 2 was not executed"> # </span>]:<span class="lineNoCov">          0 :         if ((flags = fcntl(pollset-&gt;wakeup_pipe[0]-&gt;filedes, F_GETFD)) == -1)</span>
<span class="lineNum">      96 </span>                :<span class="lineNoCov">          0 :             return errno;</span>
<span class="lineNum">      97 </span>                :            : 
<span class="lineNum">      98 </span>                :<span class="lineNoCov">          0 :         flags |= FD_CLOEXEC;</span>
<span class="lineNum">      99 </span>        [<span class="branchNoExec" title="Branch 1 was not executed"> # </span><span class="branchNoExec" title="Branch 2 was not executed"> # </span>]:<span class="lineNoCov">          0 :         if (fcntl(pollset-&gt;wakeup_pipe[0]-&gt;filedes, F_SETFD, flags) == -1)</span>
<span class="lineNum">     100 </span>                :<span class="lineNoCov">          0 :             return errno;</span>
<span class="lineNum">     101 </span>                :            :     }
<span class="lineNum">     102 </span>                :            :     {
<span class="lineNum">     103 </span>                :            :         int flags;
<span class="lineNum">     104 </span>                :            : 
<span class="lineNum">     105 </span>        [<span class="branchNoExec" title="Branch 1 was not executed"> # </span><span class="branchNoExec" title="Branch 2 was not executed"> # </span>]:<span class="lineNoCov">          0 :         if ((flags = fcntl(pollset-&gt;wakeup_pipe[1]-&gt;filedes, F_GETFD)) == -1)</span>
<span class="lineNum">     106 </span>                :<span class="lineNoCov">          0 :             return errno;</span>
<span class="lineNum">     107 </span>                :            : 
<span class="lineNum">     108 </span>                :<span class="lineNoCov">          0 :         flags |= FD_CLOEXEC;</span>
<span class="lineNum">     109 </span>        [<span class="branchNoExec" title="Branch 1 was not executed"> # </span><span class="branchNoExec" title="Branch 2 was not executed"> # </span>]:<span class="lineNoCov">          0 :         if (fcntl(pollset-&gt;wakeup_pipe[1]-&gt;filedes, F_SETFD, flags) == -1)</span>
<span class="lineNum">     110 </span>                :<span class="lineNoCov">          0 :             return errno;</span>
<span class="lineNum">     111 </span>                :            :     }
<span class="lineNum">     112 </span>                :            : 
<span class="lineNum">     113 </span>                :            :     /* Add the pipe to the pollset
<span class="lineNum">     114 </span>                :            :      */
<span class="lineNum">     115 </span>                :<span class="lineNoCov">          0 :     return apr_pollset_add(pollset, &amp;fd);</span>
<span class="lineNum">     116 </span>                :            : }
<span class="lineNum">     117 </span>                :            : #endif /* !APR_FILES_AS_SOCKETS */
<span class="lineNum">     118 </span>                :            : 
<span class="lineNum">     119 </span>                :            : /* Read and discard what's ever in the wakeup pipe.
<a name="120"><span class="lineNum">     120 </span>                :            :  */</a>
<span class="lineNum">     121 </span>                :            : void apr_pollset_drain_wakeup_pipe(apr_pollset_t *pollset)
<span class="lineNum">     122 </span>                :<span class="lineNoCov">          0 : {</span>
<span class="lineNum">     123 </span>                :            :     char rb[512];
<span class="lineNum">     124 </span>                :<span class="lineNoCov">          0 :     apr_size_t nr = sizeof(rb);</span>
<span class="lineNum">     125 </span>                :            : 
<span class="lineNum">     126 </span>        [<span class="branchNoExec" title="Branch 1 was not executed"> # </span><span class="branchNoExec" title="Branch 2 was not executed"> # </span>]:<span class="lineNoCov">          0 :     while (apr_file_read(pollset-&gt;wakeup_pipe[0], rb, &amp;nr) == APR_SUCCESS) {</span>
<span class="lineNum">     127 </span>                :            :         /* Although we write just one byte to the other end of the pipe
<span class="lineNum">     128 </span>                :            :          * during wakeup, multiple treads could call the wakeup.
<span class="lineNum">     129 </span>                :            :          * So simply drain out from the input side of the pipe all
<span class="lineNum">     130 </span>                :            :          * the data.
<span class="lineNum">     131 </span>                :            :          */
<span class="lineNum">     132 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :         if (nr != sizeof(rb))</span>
<span class="lineNum">     133 </span>                :<span class="lineNoCov">          0 :             break;</span>
<span class="lineNum">     134 </span>                :            :     }
<span class="lineNum">     135 </span>                :<span class="lineNoCov">          0 : }</span>
<a name="136"><span class="lineNum">     136 </span>                :            : </a>
<span class="lineNum">     137 </span>                :            : static apr_status_t pollset_cleanup(void *p)
<span class="lineNum">     138 </span>                :<span class="lineCov">         12 : {</span>
<span class="lineNum">     139 </span>                :<span class="lineCov">         12 :     apr_pollset_t *pollset = (apr_pollset_t *) p;</span>
<span class="lineNum">     140 </span>        [<span class="branchCov" title="Branch 0 was taken 12 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">         12 :     if (pollset-&gt;provider-&gt;cleanup) {</span>
<span class="lineNum">     141 </span>                :<span class="lineCov">         12 :         (*pollset-&gt;provider-&gt;cleanup)(pollset);</span>
<span class="lineNum">     142 </span>                :            :     }
<span class="lineNum">     143 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 12 times"> + </span>]:<span class="lineCov">         12 :     if (pollset-&gt;flags &amp; APR_POLLSET_WAKEABLE) {</span>
<span class="lineNum">     144 </span>                :            :         /* Close both sides of the wakeup pipe */
<span class="lineNum">     145 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :         if (pollset-&gt;wakeup_pipe[0]) {</span>
<span class="lineNum">     146 </span>                :            : #if APR_FILES_AS_SOCKETS
<span class="lineNum">     147 </span>                :<span class="lineNoCov">          0 :             apr_file_close(pollset-&gt;wakeup_pipe[0]);</span>
<span class="lineNum">     148 </span>                :            : #else
<span class="lineNum">     149 </span>                :            :             apr_file_socket_pipe_close(pollset-&gt;wakeup_pipe[0]);
<span class="lineNum">     150 </span>                :            : #endif
<span class="lineNum">     151 </span>                :<span class="lineNoCov">          0 :             pollset-&gt;wakeup_pipe[0] = NULL;</span>
<span class="lineNum">     152 </span>                :            :         }
<span class="lineNum">     153 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :         if (pollset-&gt;wakeup_pipe[1]) {</span>
<span class="lineNum">     154 </span>                :            : #if APR_FILES_AS_SOCKETS
<span class="lineNum">     155 </span>                :<span class="lineNoCov">          0 :             apr_file_close(pollset-&gt;wakeup_pipe[1]);</span>
<span class="lineNum">     156 </span>                :            : #else
<span class="lineNum">     157 </span>                :            :             apr_file_socket_pipe_close(pollset-&gt;wakeup_pipe[1]);
<span class="lineNum">     158 </span>                :            : #endif
<span class="lineNum">     159 </span>                :<span class="lineNoCov">          0 :             pollset-&gt;wakeup_pipe[1] = NULL;</span>
<span class="lineNum">     160 </span>                :            :         }
<span class="lineNum">     161 </span>                :            :     }
<span class="lineNum">     162 </span>                :            : 
<span class="lineNum">     163 </span>                :<span class="lineCov">         12 :     return APR_SUCCESS;</span>
<span class="lineNum">     164 </span>                :            : }
<span class="lineNum">     165 </span>                :            : 
<span class="lineNum">     166 </span>                :            : #if defined(HAVE_KQUEUE)
<span class="lineNum">     167 </span>                :            : extern apr_pollset_provider_t *apr_pollset_provider_kqueue;
<span class="lineNum">     168 </span>                :            : #endif
<span class="lineNum">     169 </span>                :            : #if defined(HAVE_PORT_CREATE)
<span class="lineNum">     170 </span>                :            : extern apr_pollset_provider_t *apr_pollset_provider_port;
<span class="lineNum">     171 </span>                :            : #endif
<span class="lineNum">     172 </span>                :            : #if defined(HAVE_EPOLL)
<span class="lineNum">     173 </span>                :            : extern apr_pollset_provider_t *apr_pollset_provider_epoll;
<span class="lineNum">     174 </span>                :            : #endif
<span class="lineNum">     175 </span>                :            : #if defined(HAVE_POLL)
<span class="lineNum">     176 </span>                :            : extern apr_pollset_provider_t *apr_pollset_provider_poll;
<span class="lineNum">     177 </span>                :            : #endif
<span class="lineNum">     178 </span>                :            : extern apr_pollset_provider_t *apr_pollset_provider_select;
<span class="lineNum">     179 </span>                :            : 
<a name="180"><span class="lineNum">     180 </span>                :            : static apr_pollset_provider_t *pollset_provider(apr_pollset_method_e method)</a>
<span class="lineNum">     181 </span>                :            : {
<span class="lineNum">     182 </span>                :<span class="lineCov">          8 :     apr_pollset_provider_t *provider = NULL;</span>
<span class="lineNum">     183 </span>  [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span><span class="branchNoExec" title="Branch 2 was not executed"> # </span><span class="branchNoExec" title="Branch 3 was not executed"> # </span>]:<span class="lineCov">          8 :     switch (method) {</span>
<span class="lineNum">         </span>  [<span class="branchCov" title="Branch 4 was taken 4 times"> + </span><span class="branchNoCov" title="Branch 5 was not taken"> - </span><span class="branchNoCov" title="Branch 6 was not taken"> - </span><span class="branchCov" title="Branch 7 was taken 4 times"> + </span>]
<span class="lineNum">         </span>  [<span class="branchNoExec" title="Branch 8 was not executed"> # </span><span class="branchNoExec" title="Branch 9 was not executed"> # </span><span class="branchNoExec" title="Branch 10 was not executed"> # </span><span class="branchNoExec" title="Branch 11 was not executed"> # </span>]
<span class="lineNum">     184 </span>                :            :         case APR_POLLSET_KQUEUE:
<span class="lineNum">     185 </span>                :            : #if defined(HAVE_KQUEUE)
<span class="lineNum">     186 </span>                :            :             provider = apr_pollset_provider_kqueue;
<span class="lineNum">     187 </span>                :            : #endif
<span class="lineNum">     188 </span>                :            :         break;
<span class="lineNum">     189 </span>                :            :         case APR_POLLSET_PORT:
<span class="lineNum">     190 </span>                :            : #if defined(HAVE_PORT_CREATE)
<span class="lineNum">     191 </span>                :            :             provider = apr_pollset_provider_port;
<span class="lineNum">     192 </span>                :            : #endif
<span class="lineNum">     193 </span>                :            :         break;
<span class="lineNum">     194 </span>                :            :         case APR_POLLSET_EPOLL:
<span class="lineNum">     195 </span>                :            : #if defined(HAVE_EPOLL)
<span class="lineNum">     196 </span>                :<span class="lineCov">          4 :             provider = apr_pollset_provider_epoll;</span>
<span class="lineNum">     197 </span>                :            : #endif
<span class="lineNum">     198 </span>                :            :         break;
<span class="lineNum">     199 </span>                :            :         case APR_POLLSET_POLL:
<span class="lineNum">     200 </span>                :            : #if defined(HAVE_POLL)
<span class="lineNum">     201 </span>                :<span class="lineNoCov">          0 :             provider = apr_pollset_provider_poll;</span>
<span class="lineNum">     202 </span>                :            : #endif
<span class="lineNum">     203 </span>                :            :         break;
<span class="lineNum">     204 </span>                :            :         case APR_POLLSET_SELECT:
<span class="lineNum">     205 </span>                :<span class="lineNoCov">          0 :             provider = apr_pollset_provider_select;</span>
<span class="lineNum">     206 </span>                :            :         break;
<span class="lineNum">     207 </span>                :            :         case APR_POLLSET_DEFAULT:
<span class="lineNum">     208 </span>                :            :         break;
<span class="lineNum">     209 </span>                :            :     }
<span class="lineNum">     210 </span>                :<span class="lineCov">          8 :     return provider;</span>
<span class="lineNum">     211 </span>                :            : }
<span class="lineNum">     212 </span>                :            : 
<span class="lineNum">     213 </span>                :            : APR_DECLARE(apr_status_t) apr_pollset_create_ex(apr_pollset_t **ret_pollset,
<span class="lineNum">     214 </span>                :            :                                                 apr_uint32_t size,
<span class="lineNum">     215 </span>                :            :                                                 apr_pool_t *p,
<span class="lineNum">     216 </span>                :            :                                                 apr_uint32_t flags,
<span class="lineNum">     217 </span>                :            :                                                 apr_pollset_method_e method)
<span class="lineNum">     218 </span>                :<span class="lineCov">          6 : {</span>
<span class="lineNum">     219 </span>                :            :     apr_status_t rv;
<span class="lineNum">     220 </span>                :            :     apr_pollset_t *pollset;
<span class="lineNum">     221 </span>                :<span class="lineCov">          6 :     apr_pollset_provider_t *provider = NULL;</span>
<span class="lineNum">     222 </span>                :            : 
<span class="lineNum">     223 </span>                :<span class="lineCov">          6 :     *ret_pollset = NULL;</span>
<span class="lineNum">     224 </span>                :            : 
<span class="lineNum">     225 </span>                :            :  #ifdef WIN32
<span class="lineNum">     226 </span>                :            :     /* Favor WSAPoll if supported.
<span class="lineNum">     227 </span>                :            :      * This will work only if ws2_32.dll has WSAPoll funtion.
<span class="lineNum">     228 </span>                :            :      * In other cases it will fall back to select() method unless
<span class="lineNum">     229 </span>                :            :      * the APR_POLLSET_NODEFAULT is added to the flags.
<span class="lineNum">     230 </span>                :            :      */
<span class="lineNum">     231 </span>                :            :     if (method == APR_POLLSET_DEFAULT) {
<span class="lineNum">     232 </span>                :            :         method = APR_POLLSET_POLL;
<span class="lineNum">     233 </span>                :            :     }
<span class="lineNum">     234 </span>                :            :  #endif
<span class="lineNum">     235 </span>                :            : 
<span class="lineNum">     236 </span>        [<span class="branchCov" title="Branch 0 was taken 2 times"> + </span><span class="branchCov" title="Branch 1 was taken 4 times"> + </span>]:<span class="lineCov">          6 :     if (method == APR_POLLSET_DEFAULT)</span>
<span class="lineNum">     237 </span>                :<span class="lineCov">          2 :         method = pollset_default_method;</span>
<span class="lineNum">     238 </span>        [<span class="branchCov" title="Branch 0 was taken 8 times"> + </span><span class="branchCov" title="Branch 1 was taken 4 times"> + </span>]:<span class="lineCov">         12 :     while (provider == NULL) {</span>
<span class="lineNum">     239 </span>                :<span class="lineCov">          8 :         provider = pollset_provider(method);</span>
<span class="lineNum">     240 </span>        [<span class="branchCov" title="Branch 0 was taken 4 times"> + </span><span class="branchCov" title="Branch 1 was taken 4 times"> + </span>]:<span class="lineCov">          8 :         if (!provider) {</span>
<span class="lineNum">     241 </span>        [<span class="branchCov" title="Branch 0 was taken 2 times"> + </span><span class="branchCov" title="Branch 1 was taken 2 times"> + </span>]:<span class="lineCov">          4 :             if ((flags &amp; APR_POLLSET_NODEFAULT) == APR_POLLSET_NODEFAULT)</span>
<span class="lineNum">     242 </span>                :<span class="lineCov">          2 :                 return APR_ENOTIMPL;</span>
<span class="lineNum">     243 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 2 times"> + </span>]:<span class="lineCov">          2 :             if (method == pollset_default_method)</span>
<span class="lineNum">     244 </span>                :<span class="lineNoCov">          0 :                 return APR_ENOTIMPL;</span>
<span class="lineNum">     245 </span>                :<span class="lineCov">          2 :             method = pollset_default_method;</span>
<span class="lineNum">     246 </span>                :            :         }
<span class="lineNum">     247 </span>                :            :     }
<span class="lineNum">     248 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 4 times"> + </span>]:<span class="lineCov">          4 :     if (flags &amp; APR_POLLSET_WAKEABLE) {</span>
<span class="lineNum">     249 </span>                :            :         /* Add room for wakeup descriptor */
<span class="lineNum">     250 </span>                :<span class="lineNoCov">          0 :         size++;</span>
<span class="lineNum">     251 </span>                :            :     }
<span class="lineNum">     252 </span>                :            : 
<span class="lineNum">     253 </span>                :<span class="lineCov">          4 :     pollset = apr_palloc(p, sizeof(*pollset));</span>
<span class="lineNum">     254 </span>                :<span class="lineCov">          4 :     pollset-&gt;nelts = 0;</span>
<span class="lineNum">     255 </span>                :<span class="lineCov">          4 :     pollset-&gt;nalloc = size;</span>
<span class="lineNum">     256 </span>                :<span class="lineCov">          4 :     pollset-&gt;pool = p;</span>
<span class="lineNum">     257 </span>                :<span class="lineCov">          4 :     pollset-&gt;flags = flags;</span>
<span class="lineNum">     258 </span>                :<span class="lineCov">          4 :     pollset-&gt;provider = provider;</span>
<span class="lineNum">     259 </span>                :            : 
<span class="lineNum">     260 </span>                :<span class="lineCov">          4 :     rv = (*provider-&gt;create)(pollset, size, p, flags);</span>
<span class="lineNum">     261 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 4 times"> + </span>]:<span class="lineCov">          4 :     if (rv == APR_ENOTIMPL) {</span>
<span class="lineNum">     262 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :         if (method == pollset_default_method) {</span>
<span class="lineNum">     263 </span>                :<span class="lineNoCov">          0 :             return rv;</span>
<span class="lineNum">     264 </span>                :            :         }
<span class="lineNum">     265 </span>                :<span class="lineNoCov">          0 :         provider = pollset_provider(pollset_default_method);</span>
<span class="lineNum">     266 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :         if (!provider) {</span>
<span class="lineNum">     267 </span>                :<span class="lineNoCov">          0 :             return APR_ENOTIMPL;</span>
<span class="lineNum">     268 </span>                :            :         }
<span class="lineNum">     269 </span>                :<span class="lineNoCov">          0 :         rv = (*provider-&gt;create)(pollset, size, p, flags);</span>
<span class="lineNum">     270 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :         if (rv != APR_SUCCESS) {</span>
<span class="lineNum">     271 </span>                :<span class="lineNoCov">          0 :             return rv;</span>
<span class="lineNum">     272 </span>                :            :         }
<span class="lineNum">     273 </span>                :<span class="lineNoCov">          0 :         pollset-&gt;provider = provider;</span>
<span class="lineNum">     274 </span>                :            :     }
<span class="lineNum">     275 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 4 times"> + </span>]:<span class="lineCov">          4 :     if (flags &amp; APR_POLLSET_WAKEABLE) {</span>
<span class="lineNum">     276 </span>                :            :         /* Create wakeup pipe */
<span class="lineNum">     277 </span>        [<span class="branchNoExec" title="Branch 1 was not executed"> # </span><span class="branchNoExec" title="Branch 2 was not executed"> # </span>]:<span class="lineNoCov">          0 :         if ((rv = create_wakeup_pipe(pollset)) != APR_SUCCESS) {</span>
<span class="lineNum">     278 </span>                :<span class="lineNoCov">          0 :             return rv;</span>
<span class="lineNum">     279 </span>                :            :         }
<span class="lineNum">     280 </span>                :            :     }
<span class="lineNum">     281 </span>[<span class="branchCov" title="Branch 0 was taken 4 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>][<span class="branchCov" title="Branch 2 was taken 4 times"> + </span><span class="branchNoCov" title="Branch 3 was not taken"> - </span>]:<span class="lineCov">          4 :     if ((flags &amp; APR_POLLSET_WAKEABLE) || provider-&gt;cleanup)</span>
<span class="lineNum">     282 </span>                :<span class="lineCov">          4 :         apr_pool_cleanup_register(p, pollset, pollset_cleanup,</span>
<span class="lineNum">     283 </span>                :            :                                   apr_pool_cleanup_null);
<span class="lineNum">     284 </span>                :            : 
<span class="lineNum">     285 </span>                :<span class="lineCov">          4 :     *ret_pollset = pollset;</span>
<span class="lineNum">     286 </span>                :<span class="lineCov">          6 :     return APR_SUCCESS;</span>
<span class="lineNum">     287 </span>                :            : }
<a name="288"><span class="lineNum">     288 </span>                :            : </a>
<span class="lineNum">     289 </span>                :            : APR_DECLARE(const char *) apr_pollset_method_name(apr_pollset_t *pollset)
<span class="lineNum">     290 </span>                :<span class="lineNoCov">          0 : {</span>
<span class="lineNum">     291 </span>                :<span class="lineNoCov">          0 :     return pollset-&gt;provider-&gt;name;</span>
<span class="lineNum">     292 </span>                :            : }
<span class="lineNum">     293 </span>                :            : 
<span class="lineNum">     294 </span>                :            : APR_DECLARE(const char *) apr_poll_method_defname()
<span class="lineNum">     295 </span>                :<span class="lineNoCov">          0 : {</span>
<span class="lineNum">     296 </span>                :<span class="lineNoCov">          0 :     apr_pollset_provider_t *provider = NULL;</span>
<span class="lineNum">     297 </span>                :            : 
<span class="lineNum">     298 </span>                :<span class="lineNoCov">          0 :     provider = pollset_provider(pollset_default_method);</span>
<span class="lineNum">     299 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :     if (provider)</span>
<span class="lineNum">     300 </span>                :<span class="lineNoCov">          0 :         return provider-&gt;name;</span>
<span class="lineNum">     301 </span>                :            :     else
<span class="lineNum">     302 </span>                :<span class="lineNoCov">          0 :         return &quot;unknown&quot;;</span>
<span class="lineNum">     303 </span>                :            : }
<span class="lineNum">     304 </span>                :            : 
<span class="lineNum">     305 </span>                :            : APR_DECLARE(apr_status_t) apr_pollset_create(apr_pollset_t **pollset,
<span class="lineNum">     306 </span>                :            :                                              apr_uint32_t size,
<a name="307"><span class="lineNum">     307 </span>                :            :                                              apr_pool_t *p,</a>
<span class="lineNum">     308 </span>                :            :                                              apr_uint32_t flags)
<span class="lineNum">     309 </span>                :<span class="lineCov">          2 : {</span>
<span class="lineNum">     310 </span>                :<span class="lineCov">          2 :     apr_pollset_method_e method = APR_POLLSET_DEFAULT;</span>
<span class="lineNum">     311 </span>                :<span class="lineCov">          2 :     return apr_pollset_create_ex(pollset, size, p, flags, method);</span>
<span class="lineNum">     312 </span>                :            : }
<a name="313"><span class="lineNum">     313 </span>                :            : </a>
<span class="lineNum">     314 </span>                :            : APR_DECLARE(apr_status_t) apr_pollset_destroy(apr_pollset_t * pollset)
<span class="lineNum">     315 </span>                :<span class="lineNoCov">          0 : {</span>
<span class="lineNum">     316 </span>[<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>][<span class="branchNoExec" title="Branch 2 was not executed"> # </span><span class="branchNoExec" title="Branch 3 was not executed"> # </span>]:<span class="lineNoCov">          0 :     if (pollset-&gt;flags &amp; APR_POLLSET_WAKEABLE ||</span>
<span class="lineNum">     317 </span>                :            :         pollset-&gt;provider-&gt;cleanup)
<span class="lineNum">     318 </span>                :<span class="lineNoCov">          0 :         return apr_pool_cleanup_run(pollset-&gt;pool, pollset,</span>
<span class="lineNum">     319 </span>                :            :                                     pollset_cleanup);
<span class="lineNum">     320 </span>                :            :     else
<span class="lineNum">     321 </span>                :<span class="lineNoCov">          0 :         return APR_SUCCESS;</span>
<span class="lineNum">     322 </span>                :            : }
<a name="323"><span class="lineNum">     323 </span>                :            : </a>
<span class="lineNum">     324 </span>                :            : APR_DECLARE(apr_status_t) apr_pollset_wakeup(apr_pollset_t *pollset)
<span class="lineNum">     325 </span>                :<span class="lineNoCov">          0 : {</span>
<span class="lineNum">     326 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :     if (pollset-&gt;flags &amp; APR_POLLSET_WAKEABLE)</span>
<span class="lineNum">     327 </span>                :<span class="lineNoCov">          0 :         return apr_file_putc(1, pollset-&gt;wakeup_pipe[1]);</span>
<span class="lineNum">     328 </span>                :            :     else
<span class="lineNum">     329 </span>                :<span class="lineNoCov">          0 :         return APR_EINIT;</span>
<span class="lineNum">     330 </span>                :            : }
<span class="lineNum">     331 </span>                :            : 
<a name="332"><span class="lineNum">     332 </span>                :            : APR_DECLARE(apr_status_t) apr_pollset_add(apr_pollset_t *pollset,</a>
<span class="lineNum">     333 </span>                :            :                                           const apr_pollfd_t *descriptor)
<span class="lineNum">     334 </span>                :<span class="lineCov">         55 : {</span>
<span class="lineNum">     335 </span>                :<span class="lineCov">         55 :     return (*pollset-&gt;provider-&gt;add)(pollset, descriptor);</span>
<span class="lineNum">     336 </span>                :            : }
<span class="lineNum">     337 </span>                :            : 
<a name="338"><span class="lineNum">     338 </span>                :            : APR_DECLARE(apr_status_t) apr_pollset_remove(apr_pollset_t *pollset,</a>
<span class="lineNum">     339 </span>                :            :                                              const apr_pollfd_t *descriptor)
<span class="lineNum">     340 </span>                :<span class="lineCov">          3 : {</span>
<span class="lineNum">     341 </span>                :<span class="lineCov">          3 :     return (*pollset-&gt;provider-&gt;remove)(pollset, descriptor);</span>
<span class="lineNum">     342 </span>                :            : }
<span class="lineNum">     343 </span>                :            : 
<span class="lineNum">     344 </span>                :            : APR_DECLARE(apr_status_t) apr_pollset_poll(apr_pollset_t *pollset,
<span class="lineNum">     345 </span>                :            :                                            apr_interval_time_t timeout,
<a name="346"><span class="lineNum">     346 </span>                :            :                                            apr_int32_t *num,</a>
<span class="lineNum">     347 </span>                :            :                                            const apr_pollfd_t **descriptors)
<span class="lineNum">     348 </span>                :<span class="lineCov">         12 : {</span>
<span class="lineNum">     349 </span>                :<span class="lineCov">         12 :     return (*pollset-&gt;provider-&gt;poll)(pollset, timeout, num, descriptors);</span>
<span class="lineNum">     350 </span>                :            : }
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.9</a></td></tr>
  </table>
  <br>

</body>
</html>
